import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from 'vuex-persistedstate';
import $http from '@/utils/request';

Vue.use(Vuex);

export default new Vuex.Store({
  //配置持久化
  plugins: [createPersistedState()],
  state: {
    phone:'',
    token:'',
  },
  getters:{
    
  },
  mutations: {
    SET_PHONE(state,payload){
      state.phone = payload
    },
    set_token(state,payload){
      state.token = payload
    }
  },
  actions: {
    LOGOUT(store,payload){
      $http.post('/user/logout').then(res =>{
        store.commit('set_token')
        store.commit('SET_PHONE')
      })
    }
  },
  modules: {},
});
